<template>
	
	  
	  
	<el-table class="mb20" :data="tableData" border style="width: 100%">
		<el-table-column prop="numbers" label="发布人手机号码" />
		<el-table-column prop="name" label="发布人姓名" />
		<el-table-column
		      prop="images"
		      label="头像"
		      width="100"      
		    >
		      <template #default="scope">		  
		          <el-image
		              style="width: 100px; height: 100px"
		              :src="scope.row.headimgurl"
		              :preview-src-list="[scope.row.headimgurl]"
		            >
		            </el-image>
		      </template>
		</el-table-column>
		<el-table-column prop="title" label="标题" />
		<el-table-column prop="description" label="话题" />
		<el-table-column
	          prop="images"
	          label="头图"
	          width="100"      
	        >
	          <template #default="scope">		  
	              <el-image
	                  style="width: 100px; height: 100px"
	                  :src="ifImgHeaders(scope.row.img)"
	                  :preview-src-list="[ifImgHeaders(scope.row.img)]"
	                >
	                </el-image>
	          </template>
	        </el-table-column>
			
			<el-table-column prop="content" label="内容" />
			<el-table-column
			      prop="images"
			      label="内容图"
			      width="100"      
			    >
			      <template #default="scope">		  
			          <el-image
			              style="width: 100px; height: 100px"
			              :src="scope.row.images[0]"
			              :preview-src-list="scope.row.images"
			            >
			            </el-image>
			      </template>
			    </el-table-column>	
		<!-- <el-table-column label="操作">
			<template #default="scope">
					<span v-if="scope.row.status==0">草稿</span>
					<span v-if="scope.row.status==2">已审核</span>
					<span v-if="scope.row.status==3">未通过</span>
				<el-button v-if="scope.row.status==1" size="mini" type="primary" @click="shenhe(scope.row.id,2)">审核</el-button>
			    <el-button v-if="scope.row.status==1" size="mini" type="primary" @click="shenhe(scope.row.id,3)">不通过</el-button>  
			</template>
		</el-table-column> -->
		<el-table-column label="操作">
			<template #default="scope">
					
				<el-button v-if="scope.row.orders==6" size="mini" type="primary" @click="zd(scope.row.id,6)">置顶</el-button>
			    <el-button v-if="scope.row.orders==10" size="mini" type="primary" @click="zd(scope.row.id,10)">取消置顶</el-button>  
			</template>
		</el-table-column>
	</el-table>
	
</template>


<script>
	import QRCode from 'qrcodejs2'
	import moment from "moment"
	import editorWang from '../components/wangEnduit'
	import {
		ElMessageBox,
		ElMessage
	} from 'element-plus'
	export default {
		components:{
			editorWang
		},
		watch:{
			times(){
				this.form.starttime=this.times[0];
				this.form.endtime=this.times[1];
			},
		},
		data() {
			return {
				viewarr:[],
				modalStatewins:false,
				hdqtxmname:"",//     名称
				hdjifen :"",//   加积分
				numbers :"",//  手机
				modalStatewin:false,
				qrcode:null,
				modalStatecode:false,
				vtimes:['',''],
				formLabelWidth: '120px',
				times:"",
				form: {
					is_show:'1',
					images:"",
					content:"",
					jifen:"",
					starttime:"",
					endtime:"",
					title:"",
					is_hot:'0',
					author:'0',
				},
				tableData:[],
				rules: {
				        title: [
				          {
				            required: true,
				            message: '请填写标题',
				            trigger: 'blur',
				          }
				        ],
						jifen: [
						  {
						    required: true,
						    message: '请填写积分',
						    trigger: 'blur',
						  }
						],
						content: [
						  {
						    required: true,
						    message: '请填写内容',
						    trigger: 'blur',
						  }
						],
						starttime: [
						  {
						    required: true,
						    message: '请选择时间',
						    trigger: 'change',
						  }
						],
				},
				pid: []
			}
		},
		mounted() {
			this.getData();		
		},
		methods: {
			editwin(id){
				this.id=id;
				this.hdqtxmname=""
				this.hdjifen =""
				this.numbers =""
				this.modalStatewin=true;
			},
		    async	shenhe(id,status){
				
		        let data = await this.$http.post("/index.php/index/Hdbm/fxnfsh",{id,status});
			
		        this.getData();	
		 
			},
			async	zd(id,status){
				
			    let data = await this.$http.post(status==6?"/index.php/index/index/userszd":"/index.php/index/index/usersqxzd",{id});
			
			    this.getData();	
					 
			},
			
			addhj(){
				this.hjarr.push([]);
			},
			scwei(wei,id){
				console.log(wei)
				if(this.qrcode){
					this.qrcode.clear(); 
				}
				this.modalStatecode=true;
				this.$nextTick(()=>{
					this.creatQrCode(JSON.stringify({wei,id})); 
				})
				
				
			},
			edites(data){
				console.log(data.row)
				data.row.is_show=data.row.is_show+'';
				delete data.row.ewmid;
				var data =JSON.parse(JSON.stringify(data.row))
				this.times=[data.starttime,data.endtime];	
			},
			changeWang(html) {
				this.form.content=html;
			    console.log(html)
			},
            creatQrCode(wei) {
				console.log(wei)
                   this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
                       text: wei+'', // 需要转换为二维码的内容
                       width: 450,
                       height: 450,
                       colorDark: '#000000',
                       colorLight: '#ffffff',
                       correctLevel: QRCode.CorrectLevel.H
                   })
               },
			getData() {
				this.$http.get("/index.php/index/Hdbm/fxnfsh").then(data => {
					data.forEach(t=>{
						t.images=t.images.split(",").map(ts=>'https://nfyfzxxcx.hansn.cn/'+ts);
					})
					this.tableData=data;

				})
			},
			submit(ref) {
				console.log(this.$refs)
				this.doRules(this.$refs[ref]).then(()=>{
					if (this.id) this.form.id = this.id;
					
					this.$http.post(this.id ? '/index.php/index/Userinfo/hdedittj' : "/index.php/index/Userinfo/hdadd",
						this.form).then(data => {
						console.log(data)
						this.modalState = false;
						ElMessage({
							message: this.id ? '编辑成功' : '新增成功',
							type: 'success',
						})
						this.getData();
					})
				})
				
			},
			remove(data){
				this.$http.post("/index.php/index/Userinfo/hddel",{id:data.row.id}).then(data => {
					ElMessage({
						message: '删除成功' ,
						type: 'success',
					})
					this.getData();
				})
			},
			handleAvatarSuccess(file) {

				this.form.image = file.data;
			},
			


		}
	}
</script>
